<template>
    <el-dialog title="学生信息" :close-on-click-modal="false" :visible.sync="visible" :before-close="cancel" append-to-body
      class="JNPF-dialog JNPF-dialog_center" width="60%">
      <el-row class="JNPF-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="学年届">
              <el-input v-model="listQuery.fitemno" placeholder="学年届" clearable />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="所属年级">
              <el-select v-model="listQuery.fcatno" placeholder="请选择" clearable>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="所属班级">
              <el-select v-model="listQuery.fcatno" placeholder="请选择" clearable>
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          
          <el-col :span="6">
            <el-form-item label="">
              <el-button type="primary" @click="getList">查询</el-button>
              <el-button type="success" @click="confirm">确认</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <el-table :data="list" border stripe height="400" highlight-current-row @current-change="raidoChange"
        @selection-change="handleSelectionChange" v-loading="loading">
        <el-table-column v-if="selecttype == 'checked'" type="selection" width="55">
        </el-table-column>
        <el-table-column prop="FYEAR" label="学年届" ></el-table-column>
        <el-table-column prop="FGRADE" label="所属年级"></el-table-column>
        <el-table-column prop="FCLASS" label="所属班级"></el-table-column>
        <el-table-column prop="FSTUDNAME" label="学生姓名"></el-table-column>
      </el-table>
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </el-dialog>
  </template>
  <script>
    export default {
      props: {
        selecttype: {
          type: String,
          default: "checked"
        },
      },
      data() {
        return {
          title: "新增",
          listQuery: {
            frtnflag: undefined,
            fitemno: undefined,
            fitemname: undefined,
            fcatno: undefined,
            fcustomno: this.$store.getters.userInfo.mobilePhone,
            page: 1,
            limit: 20,
          },
          //所属校区选择数据
        options1: [{
          value: 'L001',
          label: '大一'
        }, {
          value: 'L002',
          label: '大二'
        }, {
          value: 'L003',
          label: '大三'
        }],

        //所属校区选择数据
        options2: [{
          value: 'L001',
          label: '化学系1班'
        }, {
          value: 'L002',
          label: '化学系2班'
        }],

          list:[
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "曹操"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "刘备"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "关羽"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "张飞"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "周瑜"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "诸葛亮"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "黄忠"
                },
                {
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "化学系1班",
                  "FSTUDNAME": "马腾"
                }
              ],
          loading: false,
          total: 0,
          datalist: [],
          visible: false,
        };
      },
      created() {
      },
      mounted() { },
      methods: {
        //
        open(row) {
          this.visible = true;
        },
        confirm() {
          this.$emit("confirm", this.datalist);
          this.visible = false;
        },
        raidoChange(data) {
          if (this.selecttype == "radio") {
            this.$emit("confirm", data);
            this.visible = false;
          }
        },
        handleSelectionChange(val) {
          this.datalist = val;
        },
        //
        cancel() {
          this.visible = false;
        },
      },
    };
  </script>